package com.vercon.otamirror.dialog;

import android.os.Bundle;
import android.text.Html;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;

import com.vercon.commonmirror.base.BaseDialogFragment;
import com.vercon.otamirror.R;

/**
 * Created by csh on 2020/11/27
 */
public class DownloadfailedDialog extends BaseDialogFragment {

    private String mContent,mcommit;
    private OnDeleteDialogListener mOnDeleteDialogListener;

    @Override
    protected int setContentView(@Nullable Bundle savedInstanceState) {
        return R.layout.dialog_download_failed;
    }

    public void setString(String content,String commit) {
        this.mContent = content;
        this.mcommit = commit;
    }

    @Override
    protected void initView(View view) {
        TextView tv_content = view.findViewById(R.id.tv_content);
        tv_content.setText(Html.fromHtml(mContent));
        TextView btn_commit = view.findViewById(R.id.btn_commit);
        btn_commit.setText(Html.fromHtml(mcommit));

    }

    @Override
    protected void initListener(View view) {

        view.findViewById(R.id.btn_commit).setOnClickListener(v -> {
            if (mOnDeleteDialogListener != null) {
                mOnDeleteDialogListener.sure();
            }
        });
    }

    @Override
    protected boolean isFullScreen() {
        return false;
    }

    public void setOnDeleteDialogListener(OnDeleteDialogListener listener) {
        this.mOnDeleteDialogListener = listener;
    }

    public interface OnDeleteDialogListener {
        void sure();
    }
}